home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / SOUND / SBADLIB.ZIP / SBADLIB.TXT
Encoding:
Text File  |  1996-04-26  |  21.8 KB  |  859 lines

  1.                       Programming the AdLib/Sound Blaster
  2.  
  3.                                 FM Music Chips
  4.  
  5.                            Version 2.0 (24 Feb 1992)
  6.  
  7.  
  8.                   Copyright (c) 1991, 1992 by Jeffrey S. Lee
  9.  
  10.  
  11.                                jlee@smylex.uucp
  12.  
  13.  
  14.  
  15.  
  16.  
  17.                         Warranty and Copyright Policy
  18.  
  19.  
  20.      This document is provided on an "as-is" basis, and its author makes
  21.  
  22.      no warranty or representation, express or implied, with respect to
  23.  
  24.      its quality performance or fitness for a particular purpose.  In no
  25.  
  26.      event will the author of this document be liable for direct, indirect,
  27.  
  28.      special, incidental, or consequential damages arising out of the use
  29.  
  30.      or inability to use the information contained within.  Use of this
  31.  
  32.      document is at your own risk.
  33.  
  34.  
  35.      This file may be used and copied freely so long as the applicable
  36.  
  37.      copyright notices are retained, and no modifications are made to the
  38.  
  39.      text of the document.  No money shall be charged for its distribution
  40.  
  41.      beyond reasonable shipping, handling and duplication costs, nor shall
  42.  
  43.      proprietary changes be made to this document so that it cannot be
  44.  
  45.      distributed freely.  This document may not be included in published
  46.  
  47.      material or commercial packages without the written consent of its
  48.  
  49.      author.
  50.  
  51.  
  52.  
  53.  
  54.                                    Overview
  55.  
  56.  
  57.      Two of the most popular sound cards for the IBM-PC, the AdLib and the
  58.  
  59.      Sound Blaster, suffer from a real dearth of clear documentation for 
  60.  
  61.      programmers.  AdLib Inc. and Creative Labs, Inc. both sell developers'
  62.  
  63.      kits for their sound cards, but these are expensive, and (in the case
  64.  
  65.      of the Sound Blaster developers' kit) can be extremely cryptic.
  66.  
  67.  
  68.      This document is intended to provide programmers with a FREE source
  69.  
  70.      of information about the programming of these sound cards.
  71.  
  72.  
  73.      The information contained in this document is a combination of 
  74.  
  75.      information found in the Sound Blaster Software Developer's Kit, and
  76.  
  77.      that learned by painful experience.  Some of the information may not
  78.  
  79.      be valid for AdLib cards; if this is so, I apologize in advance.
  80.  
  81.  
  82.      Please note that numbers will be given in hexadecimal, unless otherwise
  83.  
  84.      indicated.  If a number is written out longhand (sixteen instead of 16)
  85.  
  86.      it is in decimal.
  87.  
  88.  
  89.  |   Changes from Version 1 of the file will be indicated by the use of change
  90.  
  91.  |   bars in the left-hand margin.
  92.  
  93.  
  94.  
  95.  
  96.                          Chapter One - Sound Card I/O
  97.  
  98.  
  99.      The sound card is programmed by sending data to its internal registers
  100.  
  101.      via its two I/O ports:
  102.  
  103.  
  104.              0388 (hex) - Address/Status port  (R/W)
  105.  
  106.              0389 (hex) - Data port            (W/O)
  107.  
  108.  
  109.  |   The Sound Blaster Pro is capable of stereo FM music, which is accessed
  110.  
  111.  |   in exactly the same manner.  Ports 0220 and 0221 (hex) are the address/
  112.  
  113.  |   data ports for the left speaker, and ports 0222 and 0223 (hex) are the
  114.  
  115.  |   ports for the right speaker.  Ports 0388 and 0389 (hex) will cause both
  116.  
  117.  |   speakers to output sound.
  118.  
  119.  
  120.      The sound card possesses an array of two hundred forty-four registers;
  121.  
  122.      to write to a particular register, send the register number (01-F5) to
  123.  
  124.      the address port, and the desired value to the data port.
  125.  
  126.  
  127.      After writing to the register port, you must wait twelve cycles before 
  128.  
  129.      sending the data; after writing the data, eighty-four cycles must elapse
  130.  
  131.      before any other sound card operation may be performed.
  132.  
  133.  
  134.  |   The AdLib manual gives the wait times in microseconds: three point three
  135.  
  136.  |   (3.3) microseconds for the address, and twenty-three (23) microseconds
  137.  
  138.  |   for the data.
  139.  
  140.  |
  141.  
  142.  |   The most accurate method of producing the delay is to read the register
  143.  
  144.  |   port six times after writing to the register port, and read the register
  145.  
  146.  |   port thirty-five times after writing to the data port.
  147.  
  148.  
  149.      The sound card registers are write-only.
  150.  
  151.  
  152.      The address port also functions as a sound card status byte.  To 
  153.  
  154.      retrieve the sound card's status, simply read port 388.  The status 
  155.  
  156.      byte has the following structure:
  157.  
  158.  
  159.               7      6      5      4      3      2      1      0
  160.  
  161.           +------+------+------+------+------+------+------+------+
  162.  
  163.           | both | tmr  | tmr  |              unused              |
  164.  
  165.           | tmrs |  1   |  2   |                                  |
  166.  
  167.           +------+------+------+------+------+------+------+------+
  168.  
  169.  
  170.           Bit 7 - set if either timer has expired.
  171.  
  172.               6 - set if timer 1 has expired.
  173.  
  174.               5 - set if timer 2 has expired.
  175.  
  176.  
  177.  
  178.  
  179.                        Chapter Two - The Registers
  180.  
  181.  
  182. The following table shows the function of each register in the sound 
  183.  
  184. card.  Registers will be explained in detail after the table.  Registers
  185.  
  186. not listed are unused.
  187.  
  188.  
  189.    Address      Function
  190.  
  191.    -------      ----------------------------------------------------
  192.  
  193.      01         Test LSI / Enable waveform control
  194.  
  195.      02         Timer 1 data
  196.  
  197.      03         Timer 2 data
  198.  
  199.      04         Timer control flags
  200.  
  201.      08         Speech synthesis mode / Keyboard split note select
  202.  
  203.    20..35       Amp Mod / Vibrato / EG type / Key Scaling / Multiple
  204.  
  205.    40..55       Key scaling level / Operator output level
  206.  
  207.    60..75       Attack Rate / Decay Rate
  208.  
  209.    80..95       Sustain Level / Release Rate
  210.  
  211.    A0..A8       Frequency (low 8 bits)
  212.  
  213.    B0..B8       Key On / Octave / Frequency (high 2 bits)
  214.  
  215.      BD         AM depth / Vibrato depth / Rhythm control
  216.  
  217.    C0..C8       Feedback strength / Connection type
  218.  
  219.    E0..F5       Wave Select
  220.  
  221.  
  222. The groupings of twenty-two registers (20-35, 40-55, etc.) have an odd
  223.  
  224. order due to the use of two operators for each FM voice.  The following
  225.  
  226. table shows the offsets within each group of registers for each operator.
  227.  
  228.  
  229.  
  230.    Channel        1   2   3   4   5   6   7   8   9
  231.  
  232.    Operator 1    00  01  02  08  09  0A  10  11  12
  233.  
  234.    Operator 2    03  04  05  0B  0C  0D  13  14  15
  235.  
  236.  
  237. Thus, the addresses of the attack/decay bytes for channel 3 are 62 for
  238.  
  239. the first operator, and 65 for the second.  (The address of the second
  240.  
  241. operator is always the address of the first operator plus three).
  242.  
  243.  
  244. To further illustrate the relationship, the addresses needed to control
  245.  
  246. channel 5 are:
  247.  
  248.  
  249.     29 - Operator 1  AM/VIB/EG/KSR/Multiplier
  250.  
  251.     2C - Operator 2  AM/VIB/EG/KSR/Multiplier
  252.  
  253.     49 - Operator 1  KSL/Output Level
  254.  
  255.     4C - Operator 2  KSL/Output Level
  256.  
  257.     69 - Operator 1  Attack/Decay
  258.  
  259.     6C - Operator 2  Attack/Decay
  260.  
  261.     89 - Operator 1  Sustain/Release
  262.  
  263.     8C - Operator 2  Sustain/Release
  264.  
  265.     A4 -             Frequency (low 8 bits)
  266.  
  267.     B4 -             Key On/Octave/Frequency (high 2 bits)
  268.  
  269.     C4 -             Feedback/Connection Type
  270.  
  271.     E9 - Operator 1  Waveform
  272.  
  273.     EC - Operator 2  Waveform
  274.  
  275.  
  276.  
  277.  
  278.                        Explanations of Registers
  279.  
  280.  
  281. Byte 01 - This byte is normally used to test the LSI device.  All bits
  282.  
  283.           should normally be zero.  Bit 5, if enabled, allows the FM 
  284.  
  285.           chips to control the waveform of each operator.
  286.  
  287.  
  288.              7     6     5     4     3     2     1     0
  289.  
  290.           +-----+-----+-----+-----+-----+-----+-----+-----+
  291.  
  292.           |   unused  | WS  |            unused           |
  293.  
  294.           +-----+-----+-----+-----+-----+-----+-----+-----+
  295.  
  296.  
  297.  
  298. Byte 02 - Timer 1 Data.  If Timer 1 is enabled, the value in this 
  299.  
  300.           register will be incremented until it overflows.  Upon
  301.  
  302.           overflow, the sound card will signal a TIMER interrupt
  303.  
  304.           (INT 08) and set bits 7 and 6 in its status byte.  The
  305.  
  306.           value for this timer is incremented every eighty (80)
  307.  
  308.           microseconds.
  309.  
  310.  
  311.  
  312. Byte 03 - Timer 2 Data.  If Timer 2 is enabled, the value in this 
  313.  
  314.           register will be incremented until it overflows.  Upon
  315.  
  316.           overflow, the sound card will signal a TIMER interrupt
  317.  
  318.           (INT 08) and set bits 7 and 5 in its status byte.  The
  319.  
  320.           value for this timer is incremented every three hundred
  321.  
  322.           twenty (320) microseconds.
  323.  
  324.  
  325.  
  326. Byte 04 - Timer Control Byte
  327.  
  328.  
  329.         7     6     5     4     3     2     1     0
  330.  
  331.      +-----+-----+-----+-----+-----+-----+-----+-----+
  332.  
  333.      | IRQ | T1  | T2  |     unused      | T2  | T1  |
  334.  
  335.      | RST | MSK | MSK |                 | CTL | CTL |
  336.  
  337.      +-----+-----+-----+-----+-----+-----+-----+-----+
  338.  
  339.  
  340.           bit 7 - Resets the flags for timers 1 & 2.  If set,
  341.  
  342.                   all other bits are ignored.
  343.  
  344.           bit 6 - Masks Timer 1.  If set, bit 0 is ignored.
  345.  
  346.           bit 5 - Masks Timer 2.  If set, bit 1 is ignored.
  347.  
  348.           bit 1 - When clear, Timer 2 does not operate.
  349.  
  350.                   When set, the value from byte 03 is loaded into
  351.  
  352.                   Timer 2, and incrementation begins.
  353.  
  354.           bit 0 - When clear, Timer 1 does not operate.
  355.  
  356.                   When set, the value from byte 02 is loaded into
  357.  
  358.                   Timer 1, and incrementation begins.
  359.  
  360.  
  361.  
  362. Byte 08 - CSM Mode / Keyboard Split.
  363.  
  364.  
  365.         7     6     5     4     3     2     1     0
  366.  
  367.      +-----+-----+-----+-----+-----+-----+-----+-----+
  368.  
  369.      | CSM | Key |              unused               |
  370.  
  371.      | sel | Spl |                                   |
  372.  
  373.      +-----+-----+-----+-----+-----+-----+-----+-----+
  374.  
  375.      
  376.  
  377.           bit 7 - When set, selects composite sine-wave speech synthesis
  378.  
  379.                   mode (all KEY-ON bits must be clear).  When clear,
  380.  
  381.                   selects FM music mode.
  382.  
  383.  
  384.           bit 6 - Selects the keyboard split point (in conjunction with
  385.  
  386.                   the F-Number data).  The documentation in the Sound 
  387.  
  388.                   Blaster manual is utterly incomprehensible on this;
  389.  
  390.                   I can't reproduce it without violating their copyright.
  391.  
  392.  
  393.  
  394. Bytes 20-35 - Amplitude Modulation / Vibrato / Envelope Generator Type /
  395.  
  396.               Keyboard Scaling Rate / Modulator Frequency Multiple
  397.  
  398.  
  399.         7     6     5     4     3     2     1     0
  400.  
  401.      +-----+-----+-----+-----+-----+-----+-----+-----+
  402.  
  403.      | Amp | Vib | EG  | KSR |  Modulator Frequency  |
  404.  
  405.      | Mod |     | Typ |     |       Multiple        |
  406.  
  407.      +-----+-----+-----+-----+-----+-----+-----+-----+
  408.  
  409.  
  410.           bit 7 - Apply amplitude modulation when set; AM depth is
  411.  
  412.                   controlled by the AM-Depth flag in address BD.
  413.  
  414.           bit 6 - Apply vibrato when set;  vibrato depth is controlled
  415.  
  416.                   by the Vib-Depth flag in address BD.
  417.  
  418.           bit 5 - When set, the sustain level of the voice is maintained
  419.  
  420.                   until released; when clear, the sound begins to decay
  421.  
  422.                   immediately after hitting the SUSTAIN phase.
  423.  
  424.           bit 4 - Keyboard scaling rate.  This is another incomprehensible
  425.  
  426.                   bit in the Sound Blaster manual.  From experience, if 
  427.  
  428.                   this bit is set, the sound's envelope is foreshortened as
  429.  
  430.                   it rises in pitch.
  431.  
  432.           bits 3-0 - These bits indicate which harmonic the operator will 
  433.  
  434.                   produce sound (or modulation) in relation to the voice's 
  435.  
  436.                   specified frequency:
  437.  
  438.  
  439.                       0 - one octave below
  440.  
  441.                       1 - at the voice's specified frequency
  442.  
  443.                       2 - one octave above
  444.  
  445.                       3 - an octave and a fifth above
  446.  
  447.                       4 - two octaves above
  448.  
  449.                       5 - two octaves and a major third above
  450.  
  451.                       6 - two octaves and a fifth above
  452.  
  453.                       7 - two octaves and a minor seventh above
  454.  
  455.                       8 - three octaves above
  456.  
  457.                       9 - three octaves and a major second above
  458.  
  459.                       A - three octaves and a major third above
  460.  
  461.                       B -  "       "     "  "   "     "     "
  462.  
  463.                       C - three octaves and a fifth above
  464.  
  465.                       D -   "      "     "  "   "     "
  466.  
  467.                       E - three octaves and a major seventh above
  468.  
  469.                       F -   "      "     "  "   "      "      "
  470.  
  471.                   
  472.  
  473.  
  474. Bytes 40-55 - Level Key Scaling / Total Level
  475.  
  476.  
  477.         7     6     5     4     3     2     1     0
  478.  
  479.      +-----+-----+-----+-----+-----+-----+-----+-----+
  480.  
  481.      |  Scaling  |             Total Level           |
  482.  
  483.      |   Level   | 24    12     6     3    1.5   .75 | <-- dB
  484.  
  485.      +-----+-----+-----+-----+-----+-----+-----+-----+
  486.  
  487.  
  488.           bits 7-6 - causes output levels to decrease as the frequency
  489.  
  490.                      rises:
  491.  
  492.  
  493.                           00   -  no change
  494.  
  495.                           10   -  1.5 dB/8ve
  496.  
  497.                           01   -  3 dB/8ve
  498.  
  499.                           11   -  6 dB/8ve
  500.  
  501.  
  502.           bits 5-0 - controls the total output level of the operator.
  503.  
  504.                      all bits CLEAR is loudest; all bits SET is the
  505.  
  506.                      softest.  Don't ask me why.
  507.  
  508.  
  509.  
  510. Bytes 60-75 - Attack Rate / Decay Rate
  511.  
  512.  
  513.         7     6     5     4     3     2     1     0
  514.  
  515.      +-----+-----+-----+-----+-----+-----+-----+-----+
  516.  
  517.      |         Attack        |          Decay        |
  518.  
  519.      |          Rate         |          Rate         |
  520.  
  521.      +-----+-----+-----+-----+-----+-----+-----+-----+
  522.  
  523.  
  524.           bits 7-4 - Attack rate.  0 is the slowest, F is the fastest.
  525.  
  526.           bits 3-0 - Decay rate.  0 is the slowest, F is the fastest.
  527.  
  528.  
  529.  
  530. Bytes 80-95 - Sustain Level / Release Rate
  531.  
  532.  
  533.         7     6     5     4     3     2     1     0
  534.  
  535.      +-----+-----+-----+-----+-----+-----+-----+-----+
  536.  
  537.      |     Sustain Level     |         Release       |
  538.  
  539.      | 24    12     6     3  |          Rate         |
  540.  
  541.      +-----+-----+-----+-----+-----+-----+-----+-----+
  542.  
  543.  
  544.           bits 7-4 - Sustain Level.  0 is the loudest, F is the softest.
  545.  
  546.           bits 3-0 - Release Rate.  0 is the slowest, F is the fastest.
  547.  
  548.  
  549.  
  550. Bytes A0-B8 - Octave / F-Number / Key-On
  551.  
  552.  
  553.         7     6     5     4     3     2     1     0
  554.  
  555.      +-----+-----+-----+-----+-----+-----+-----+-----+
  556.  
  557.      |        F-Number (least significant byte)      |  (A0-A8)
  558.  
  559.      |                                               |
  560.  
  561.      +-----+-----+-----+-----+-----+-----+-----+-----+
  562.  
  563.  
  564.         7     6     5     4     3     2     1     0
  565.  
  566.      +-----+-----+-----+-----+-----+-----+-----+-----+
  567.  
  568.      |  Unused   | Key |    Octave       | F-Number  |  (B0-B8)
  569.  
  570.      |           | On  |                 | most sig. |
  571.  
  572.      +-----+-----+-----+-----+-----+-----+-----+-----+
  573.  
  574.  
  575.           bit   5  - Channel is voiced when set, silent when clear.
  576.  
  577.           bits 4-2 - Octave (0-7).  0 is lowest, 7 is highest.
  578.  
  579.           bits 1-0 - Most significant bits of F-number.
  580.  
  581.  
  582.      In octave 4, the F-number values for the chromatic scale and their 
  583.  
  584.      corresponding frequencies would be:
  585.  
  586.  
  587.         F Number     Frequency     Note
  588.  
  589.            16B          277.2       C#
  590.  
  591.            181          293.7       D
  592.  
  593.            198          311.1       D#
  594.  
  595.            1B0          329.6       E
  596.  
  597.            1CA          349.2       F
  598.  
  599.            1E5          370.0       F#
  600.  
  601.            202          392.0       G
  602.  
  603.            220          415.3       G#
  604.  
  605.            241          440.0       A
  606.  
  607.            263          466.2       A#
  608.  
  609.            287          493.9       B
  610.  
  611.            2AE          523.3       C
  612.  
  613.  
  614.  
  615. Bytes C0-C8 - Feedback / Algorithm
  616.  
  617.  
  618.         7     6     5     4     3     2     1     0
  619.  
  620.      +-----+-----+-----+-----+-----+-----+-----+-----+
  621.  
  622.      |         unused        |    Feedback     | Alg |
  623.  
  624.      |                       |                 |     |
  625.  
  626.      +-----+-----+-----+-----+-----+-----+-----+-----+
  627.  
  628.  
  629.           bits 3-1 - Feedback strength.  If all three bits are set to
  630.  
  631.                      zero, no feedback is present.  With values 1-7,
  632.  
  633.                      operator 1 will send a portion of its output back
  634.  
  635.                      into itself.  1 is the least amount of feedback,
  636.  
  637.                      7 is the most.
  638.  
  639.           bit 0    - If set to 0, operator 1 modulates operator 2.  In this
  640.  
  641.                      case, operator 2 is the only one producing sound.
  642.  
  643.                      If set to 1, both operators produce sound directly.
  644.  
  645.                      Complex sounds are more easily created if the algorithm
  646.  
  647.                      is set to 0.
  648.  
  649.  
  650.  
  651. Byte BD - Amplitude Modulation Depth / Vibrato Depth / Rhythm
  652.  
  653.  
  654.         7     6     5     4     3     2     1     0
  655.  
  656.      +-----+-----+-----+-----+-----+-----+-----+-----+
  657.  
  658.      | AM  | Vib | Rhy | BD  | SD  | TOM | Top | HH  |
  659.  
  660.      | Dep | Dep | Ena |     |     |     | Cym |     |
  661.  
  662.      +-----+-----+-----+-----+-----+-----+-----+-----+
  663.  
  664.  
  665.           bit 7 - Set:    AM depth is 4.8dB
  666.  
  667.                   Clear:  AM depth is 1 dB
  668.  
  669.           bit 6 - Set:    Vibrato depth is 14 cent
  670.  
  671.                   Clear:  Vibrato depth is 7 cent
  672.  
  673.           bit 5 - Set:    Rhythm enabled  (6 melodic voices) 
  674.  
  675.                   Clear:  Rhythm disabled (9 melodic voices)
  676.  
  677.           bit 4 - Bass drum on/off
  678.  
  679.           bit 3 - Snare drum on/off
  680.  
  681.           bit 2 - Tom tom on/off
  682.  
  683.           bit 1 - Cymbal on/off
  684.  
  685.           bit 0 - Hi Hat on/off
  686.  
  687.  
  688.           Note:  KEY-ON registers for channels 06, 07, and 08 must be OFF
  689.  
  690.                  in order to use the rhythm section.  Other parameters
  691.  
  692.                  such as attack/decay/sustain/release must also be set
  693.  
  694.                  appropriately.
  695.  
  696.  
  697.  
  698. Bytes E0-F5 - Waveform Select
  699.  
  700.  
  701.         7     6     5     4     3     2     1     0
  702.  
  703.      +-----+-----+-----+-----+-----+-----+-----+-----+
  704.  
  705.      |               unused              |  Waveform |
  706.  
  707.      |                                   |  Select   |
  708.  
  709.      +-----+-----+-----+-----+-----+-----+-----+-----+
  710.  
  711.  
  712.           bits 1-0 - When bit 5 of address 01 is set, the output waveform
  713.  
  714.                      will be distorted according to the waveform indicated
  715.  
  716.                      by these two bits.  I'll try to diagram them here,
  717.  
  718.                      but this medium is fairly restrictive.
  719.  
  720.  
  721.          ___              ___            ___    ___       _      _
  722.  
  723.         /   \            /   \          /   \  /   \     / |    / |
  724.  
  725.        /_____\_______   /_____\_____   /_____\/_____\   /__|___/__|___
  726.  
  727.               \     /
  728.  
  729.                \___/
  730.  
  731.  
  732.             00              01               10               11
  733.  
  734.  
  735.  
  736.  
  737.  |                          Detecting a Sound Card
  738.  
  739.  |
  740.  
  741.  |   According to the AdLib manual, the 'official' method of checking for a 
  742.  
  743.  |   sound card is as follows:
  744.  
  745.  |
  746.  
  747.  |      1)  Reset both timers by writing 60h to register 4.
  748.  
  749.  |      2)  Enable the interrupts by writing 80h to register 4.  NOTE: this
  750.  
  751.  |          must be a separate step from number 1.
  752.  
  753.  |      3)  Read the status register (port 388h).  Store the result.
  754.  
  755.  |      4)  Write FFh to register 2 (Timer 1).
  756.  
  757.  |      5)  Start timer 1 by writing 21h to register 4.
  758.  
  759.  |      6)  Delay for at least 80 microseconds.
  760.  
  761.  |      7)  Read the status register (port 388h).  Store the result.
  762.  
  763.  |      8)  Reset both timers and interrupts (see steps 1 and 2).
  764.  
  765.  |      9)  Test the stored results of steps 3 and 7 by ANDing them
  766.  
  767.  |          with E0h.  The result of step 3 should be 00h, and the 
  768.  
  769.  |          result of step 7 should be C0h.  If both are correct, an
  770.  
  771.  |          AdLib-compatible board is installed in the computer.
  772.  
  773.  |
  774.  
  775.  |
  776.  
  777.  |                              Making a Sound
  778.  
  779.  | 
  780.  
  781.  |   Many people have asked me, upon reading this document, what the proper
  782.  
  783.  |   register values should be to make a simple sound.  Well, here they are.
  784.  
  785.  | 
  786.  
  787.  |   First, clear out all of the registers by setting all of them to zero.
  788.  
  789.  |   This is the quick-and-dirty method of resetting the sound card, but it
  790.  
  791.  |   works.  Note that if you wish to use different waveforms, you must then
  792.  
  793.  |   turn on bit 5 of register 1.  (This reset need be done only once, at the
  794.  
  795.  |   start of the program, and optionally when the program exits, just to 
  796.  
  797.  |   make sure that your program doesn't leave any notes on when it exits.)
  798.  
  799.  |
  800.  
  801.  |   Now, set the following registers to the indicated value:
  802.  
  803.  |
  804.  
  805.  |     REGISTER     VALUE     DESCRIPTION
  806.  
  807.  |        20          01      Set the modulator's multiple to 1
  808.  
  809.  |        40          10      Set the modulator's level to about 40 dB
  810.  
  811.  |        60          F0      Modulator attack:  quick;   decay:   long
  812.  
  813.  |        80          77      Modulator sustain: medium;  release: medium
  814.  
  815.  |        A0          98      Set voice frequency's LSB (it'll be a D#)
  816.  
  817.  |        23          01      Set the carrier's multiple to 1
  818.  
  819.  |        43          00      Set the carrier to maximum volume (about 47 dB)
  820.  
  821.  |        63          F0      Carrier attack:  quick;   decay:   long
  822.  
  823.  |        83          77      Carrier sustain: medium;  release: medium
  824.  
  825.  |        B0          31      Turn the voice on; set the octave and freq MSB
  826.  
  827.  |
  828.  
  829.  |   To turn the voice off, set register B0h to 11h (or, in fact, any value 
  830.  
  831.  |   which leaves bit 5 clear).  It's generally preferable, of course, to
  832.  
  833.  |   induce a delay before doing so.
  834.  
  835.  |
  836.  
  837.  |
  838.  
  839.  |                             Acknowledgements
  840.  
  841.  |
  842.  
  843.  |   Thanks are due to the following people:
  844.  
  845.  |
  846.  
  847.  |   Ezra M. Dreisbach (ed10+@andrew.cmu.edu), for providing the information
  848.  
  849.  |     about the recommended port write delay from the AdLib manual, and the
  850.  
  851.  |     'official' method of detecting an AdLib-compatible sound card.
  852.  
  853.  |
  854.  
  855.  |   Nathan Isaac Laredo (gt7080a@prism.gatech.edu), for providing the
  856.  
  857.  |     port numbers for stereo sound on the Sound Blaster Pro.
  858.  
  859.